#ifndef MPP_DEC_H
#define MPP_DEC_H

#include <iostream>

extern "C" {
#include <stdio.h>
#include <time.h>
#include <signal.h>
#include <unistd.h>
#include "rk_mpi.h"
#include "mpp_mem.h"
#include "mpp_common.h"
};

#define msleep(x)               usleep((x)*1000)

struct FileSource {
    int display;
    int width;
    int height;
    std::string input;
    std::string output;
    MppCodingType type;
};

class decodec
{
private:
    int mFps;
    int mEos;
    int mDisPlay;   
    int mFrmCnt;
    int srcW;       
    int srcH;       
    int dstW;       
    int dstH;
    size_t max_usage;       

    RK_S64 mTimeS;
    RK_S64 mTimeE;
    RK_S64 mTimeDiff;
    float mFrmRate;

    FILE *mFin;     
    FILE *mFout;   
    char *mPktBuf;  

    MppCtx mCtx;                
    MppApi *mApi;              
    MppPacket mPkt;             
    MppBuffer mBuffer;
    MppBufferGroup mFrmGrp;
public:
    decodec();
    ~decodec();
    
    int init(void *args);
    int decode();
    void dump_mpp_frame_to_file(MppFrame frame, FILE *fp);
    int deinit();
};

#endif